package com.yc.designMode.cor;

import java.util.ArrayList;
import java.util.List;

public class FilterChainImpl implements FilterChain {

	List<Filter> filterList = new ArrayList<Filter>();
	int index = 0;
	
	@Override
	public void doFilter(Request req, Response res) {
		if (index >= filterList.size())
			return;//如果处理完就结束
		
		//执行request处理
		filterList.get(index).doFilter(req, res, this);
		index++;//指针指向下一个
		
	}
	
	public void addFilter(Filter filter) {
		filterList.add(filter);
	}

}
